<template>
  <div class="membersetup-contianter fillcontain">
    <breadcrumb></breadcrumb>
    <div class="content">
      <div class="container">
        <el-main>
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>待付款订单</span>
            </div>
            <el-form label-width="100px">
              <el-form-item label="自动取消时间为" label-width="120px">
                <el-input v-model="paymentDay"></el-input>
                <span>天&nbsp;</span>&nbsp;
                <el-input v-model="paymentHour"></el-input>
                <span>时&nbsp;</span>&nbsp;
                <el-input v-model="paymentMinute"></el-input>
                <span>分&nbsp;</span>&nbsp;
              </el-form-item>
            </el-form>
          </el-card>
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>待收货订单</span>
            </div>
            <el-form label-width="100px">
              <el-form-item label="发货后" label-width="120px">
                <el-input v-model="receiptDay"></el-input>
                <span>天&nbsp;</span>&nbsp;
                <el-input v-model="receiptHour"></el-input>
                <span>时&nbsp;</span>&nbsp;
                <el-input v-model="receiptMinute"></el-input>
                <span>分&nbsp;</span>&nbsp;自动确认收货
              </el-form-item>
            </el-form>
          </el-card>
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>售后订单</span>
            </div>
            <el-form label-width="100px">
              <el-form-item label="确认收货" label-width="120px">
                <el-input v-model="notApplyAfterSalesDay"></el-input>
                <span>天&nbsp;</span>&nbsp;
                <el-input v-model="f1" readonly></el-input>
                <span>时&nbsp;</span>&nbsp;
                <el-input v-model="f1" readonly></el-input>
                <span>分&nbsp;</span>&nbsp;自动确认收货
                后，买家不可以申请售后
              </el-form-item>
            </el-form>
          </el-card>

          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>待评价订单</span>
            </div>
            <el-form label-width="100px">
              <el-form-item label="确认收货后" label-width="120px">
                <el-input v-model="highPraiseDay"></el-input>
                <span>天&nbsp;</span>&nbsp;
                <el-input v-model="highPraiseHour"></el-input>
                <span>时&nbsp;</span>&nbsp;
                <el-input v-model="highPraiseMinute"></el-input>
                <span>分&nbsp;</span>&nbsp;自动好评
              </el-form-item>
            </el-form>
          </el-card>
        </el-main>
        <el-footer>
          <el-button type="primary" @click="modifyOrder">确定</el-button>
          <el-button style="color:#409EFF " @click="get_list()">取消</el-button>
        </el-footer>
      </div>
    </div>
  </div>
</template>

<script>
import breadcrumb from "../../components/breadcrumb";
export default {
  components: { breadcrumb },
  data() {
    return {
      readonly: true,
      f1: "00",
      paymentDay: "",
      paymentHour: "",
      paymentMinute: "",
      receiptDay: "",
      receiptHour: "",
      receiptMinute: "",
      notApplyAfterSalesDay: "",
      highPraiseDay: "",
      highPraiseHour: "",
      highPraiseMinute: "",
      highPraiseId: "",
      notApplyAfterSalesId: "",
      paymentId: "",
      receiptId: ""
    };
  },
  created() {
    this.get_list();
  },
  methods: {
    get_list() {
      this.$axios.post("/web_order/get_config").then(result => {
        if (result.data.status == 0) {
          let data = result.data.data;
          this.highPraiseDay = data.highPraiseDay;
          this.highPraiseHour = data.highPraiseHour;
          this.highPraiseId = data.highPraiseId;
          this.highPraiseMinute = data.highPraiseMinute;
          this.notApplyAfterSalesDay = data.notApplyAfterSalesDay;
          this.notApplyAfterSalesId = data.notApplyAfterSalesId;
          this.paymentDay = data.paymentDay;
          this.paymentHour = data.paymentHour;
          this.paymentId = data.paymentId;
          this.paymentMinute = data.paymentMinute;
          this.receiptDay = data.receiptDay;
          this.receiptHour = data.receiptHour;
          this.receiptId = data.receiptId;
          this.receiptMinute = data.receiptMinute;
        }
      });
    },

    modifyOrder() {
      if (
        !/^([0-9]|(1)[0-5])$/.test(this.paymentDay) ||
        !/^([0-9]|(1)[0-5])$/.test(this.receiptDay) ||
        !/^([0-9]|(1)[0-5])$/.test(this.notApplyAfterSalesDay) ||
        !/^([0-9]|(1)[0-5])$/.test(this.highPraiseDay)
      ) {
        this.get_list();
        return this.$message({
          type: "warning",
          message: "输入的天数不能为空且不能超过15天"
        });
      }
      if (
        !/^(0|0?[1-9]|1[0-9]|2[0-3])$/.test(this.paymentHour) ||
        !/^(0|0?[1-9]|1[0-9]|2[0-3])$/.test(this.receiptHour) ||
        !/^(0|0?[1-9]|1[0-9]|2[0-3])$/.test(this.highPraiseHour)
      ) {
        this.get_list();
        return this.$message({
          type: "warning",
          message: "输入的小时数不能为空且取值范围为0~23"
        });
      }
      if (
        !/^(0|(0?[1-9])|((1|2|3|4|5)[0-9]))$/.test(this.paymentMinute) ||
        !/^(0|(0?[1-9])|((1|2|3|4|5)[0-9]))$/.test(this.receiptMinute) ||
        !/^(0|(0?[1-9])|((1|2|3|4|5)[0-9]))$/.test(this.highPraiseMinute)
      ) {
        this.get_list();
        return this.$message({
          type: "warning",
          message: "输入的分钟数不能为空且取值范围为0~59"
        });
      }
      var data;
      if (
        this.highPraiseId &&
        this.notApplyAfterSalesId &&
        this.paymentId &&
        this.receiptId
      ) {
        // data =
        //   "highPraiseDay=" +
        //   this.highPraiseDay +
        //   "&highPraiseId=" +
        //   this.highPraiseId +
        //   "&notApplyAfterSalesId=" +
        //   this.notApplyAfterSalesId +
        //   "&paymentId=" +
        //   this.paymentId +
        //   "&receiptId=" +
        //   this.receiptId +
        //   "&highPraiseHour=" +
        //   this.highPraiseHour +
        //   "&highPraiseMinute=" +
        //   this.highPraiseMinute +
        //   "&notApplyAfterSalesDay=" +
        //   this.notApplyAfterSalesDay +
        //   "&paymentDay=" +
        //   this.paymentDay +
        //   "&paymentHour=" +
        //   this.paymentHour +
        //   "&paymentMinute=" +
        //   this.paymentMinute +
        //   "&receiptDay=" +
        //   this.receiptDay +
        //   "&receiptHour=" +
        //   this.receiptHour +
        //   "&receiptMinute=" +
        //   this.receiptMinute;
        data = {
          highPraiseDay: this.highPraiseDay,
          highPraiseHour: this.highPraiseHour,
          highPraiseMinute: this.highPraiseMinute,
          highPraiseId: this.highPraiseId,
          notApplyAfterSalesDay: this.notApplyAfterSalesDay,
          notApplyAfterSalesId: this.notApplyAfterSalesId,
          paymentDay: this.paymentDay,
          paymentHour: this.paymentHour,
          paymentMinute: this.paymentMinute,
          paymentId: this.paymentId,
          receiptDay: this.receiptDay,
          receiptHour: this.receiptHour,
          receiptId: this.receiptId,
          receiptMinute: this.receiptMinute
        };
      } else {
        // data =
        //   "highPraiseDay=" +
        //   this.highPraiseDay +
        //   "&highPraiseHour=" +
        //   this.highPraiseHour +
        //   "&highPraiseMinute=" +
        //   this.highPraiseMinute +
        //   "&notApplyAfterSalesDay=" +
        //   this.notApplyAfterSalesDay +
        //   "&paymentDay=" +
        //   this.paymentDay +
        //   "&paymentHour=" +
        //   this.paymentHour +
        //   "&paymentMinute=" +
        //   this.paymentMinute +
        //   "&receiptDay=" +
        //   this.receiptDay +
        //   "&receiptHour=" +
        //   this.receiptHour +
        //   "&receiptMinute=" +
        //   this.receiptMinute;
        data = {
          highPraiseDay: this.highPraiseDay,
          highPraiseHour: this.highPraiseHour,
          highPraiseMinute: this.highPraiseMinute,
          notApplyAfterSalesDay: this.notApplyAfterSalesDay,
          paymentDay: this.paymentDay,
          paymentHour: this.paymentHour,
          paymentMinute: this.paymentMinute,
          receiptDay: this.receiptDay,
          receiptHour: this.receiptHour,
          receiptMinute: this.receiptMinute
        };
      }
      //console.log(data, "ttttt");

      this.$axios.post("/web_order/saveOrUpdate_config", data).then(result => {
        if (result.data.status == 0) {
          if (result.data.data == true) {
            this.get_list();
            return this.$message({
              type: "success",
              message: "操作成功"
            });
          } else {
            return this.$message({
              type: "warning",
              message: "操作失败"
            });
          }
        }
      });
    }
  }
};
</script>

<style lang="less">
.membersetup-contianter {
  position: relative;
  .el-form-item__label {
    text-align: left;
  }
  .el-input__inner {
    line-height: 30px;
    height: 30px;
    width: 150px;
  }
  .breadcrumb-container {
    position: absolute;
    width: 100%;
  }
  .content {
    .el-card.is-always-shadow {
      box-shadow: none;
    }
    background-color: #eff3f6;
    padding: 60px 20px 20px;
    height: 100%;
    box-sizing: border-box;
    .container {
      background-color: #fff;
      height: 100%;
      .el-main {
        background-color: #fff;
        .box-card {
          border: none;
          .el-input {
            width: 65px !important;
            .el-input__inner {
              width: 50px;
            }
          }
          .el-card__header {
            line-height: 60px;
            padding: 0;
            border-bottom: none;
            color: #5e70e6;
            font-size: 16px;
          }
          .el-card__body {
            display: flex;
            padding: 0;
            .el-form {
              padding-left: 20px;

              .el-form-item {
                .el-form-item__content {
                  display: flex;
                  .el-input {
                    width: 160px;
                  }
                }
              }
            }
          }
        }
      }
      .el-footer {
        padding-left: 300px;
        button {
          margin: 0 40px;
          height: 30px;
          width: 70px;
          padding: 0;
        }
      }
    }
  }
}
</style>

